package com.taglab.chic.search.impl;

import com.taglab.chic.search.Query;
import com.taglab.chic.search.SearchResult;
import com.taglab.chic.search.SearchResults;

import java.util.List;
import java.util.LinkedList;
import java.util.Date;

/**
 * @author Markus Kobler
*/
class ResultBuilder {

  private Date created = new Date();

  private Query query;

  private List<SearchResult> results = new LinkedList<SearchResult>();

  private int total = 0;

  ResultBuilder(Query query) {
    if( query == null) throw new NullPointerException();
    this.query = query;
  }

  public void addResult(SearchResult result) {
    results.add(result);
  }

  public void setTotalResults(int total) {
    this.total = total;
  }

  public SearchResults createResults() {
    return new SearchResults(query, results, total);
  }

  public Date getCreated() {
    return created;
  }

}
